package top.chj.day16.dateclass;

import org.junit.Test;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Auther:小陈的Java
 * 日期格式
 */
public class Dateformat {
    @Test
    public void method1(){
        LocalDateTime localDateTime= LocalDateTime.now();
        String format = localDateTime.format(DateTimeFormatter.ISO_DATE_TIME);
        System.out.println(format);
        String str = "2012-12-12T23:23:59.55";
        LocalDateTime localDateTime1 = LocalDateTime.parse(str, DateTimeFormatter.ISO_DATE_TIME);
        System.out.println(localDateTime1);
    }
    @Test
    public void method2(){
        LocalDateTime localDateTime= LocalDateTime.now();
        String format = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        String str = "2012-12-12T23:23:59.55";
        LocalDateTime localDateTime1 = LocalDateTime.parse(str, DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss:SSS"));
        System.out.println(localDateTime1);
    }
}
